<?php
class FeedbackController extends DomController {
	
	public function feedback() {

		$view = new DomView('feedback.html');
		
		if( $_POST['send'] == 1 ) {
			
			if( $_POST['email'] != $_POST['emailAgain'] ) {
				$view->errorMessage = 'Emailid ei ole samad';
			
			} else {
				$mail  = new Mail();
				$mail->CharSet = 'utf-8';
				
				$mail->AddAddress( 'info@mySite.com' );  
				$mail->Subject =  'Tagasiside - '.$_POST['title'];
				$mail->Body = $_POST['contents'];
				$mail->From = $_POST['email'];
				$mail->FromName = $_POST['email'];
				
				if( $mail->Send() ) {
					$view->okMessage = 'Teade saadetud';
				} else {
					$view->errorMessage = 'Teate saatmine ebaõnnestus';
				}
			}
		}
		
		$this->view->contents = $view->fetch();
	}
}
?>